import { ref, computed, nextTick } from "vue";

export function CommonFn() {
    let animationState = ref('paused')
    let isAnimation = ref(true)

    const start = () => {
        animationState.value = "running"
    }
    const paused = () => {
        animationState.value = "paused"
    }
    const rest = (dealy: number = 200) => {
        paused()
        isAnimation.value = false
        setTimeout(() => {
            nextTick(() => {
                isAnimation.value = true
                start()
            })
        }, dealy)

    }




    return {
        isAnimation,
        animationState,
        start,
        paused,
        rest
    }
}

export function getTextArr(props: { text: string }) {
    let texts = computed(() => {
        let current = props.text
        if (current) {
            return current.split('')
        }

        return []
    })

    return { texts }
} 